package com.ruoyi.web.controller.wq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqPlay;
import com.ruoyi.wq.domain.vo.WqPlayVO;
import com.ruoyi.wq.service.IWqPlayService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 陪玩类目Controller
 * 
 * @author ruoyi
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/wq/play")
public class WqPlayController extends BaseController {

    @Autowired
    private IWqPlayService wqPlayService;

    /**
     * 查询陪玩列表
     */
    @GetMapping("/getList")
    public AjaxResult getList(WqPlayVO wqPlay){
    	AjaxResult ajax = AjaxResult.success();
    	List<WqPlayVO> playList = wqPlayService.getList(wqPlay);
    	ajax.put("playList", playList);
        return ajax;
    }

    /**
     * 导出陪玩类目列表
     */
    @PreAuthorize("@ss.hasPermi('wq:play:export')")
    @Log(title = "陪玩类目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqPlay wqPlay)
    {
        List<WqPlay> list = wqPlayService.selectWqPlayList(wqPlay);
        ExcelUtil<WqPlay> util = new ExcelUtil<WqPlay>(WqPlay.class);
        util.exportExcel(response, list, "陪玩类目数据");
    }

    /**
     * 获取陪玩类目详细信息
     */
    @PreAuthorize("@ss.hasPermi('wq:play:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(wqPlayService.selectWqPlayById(id));
    }

    /**
     * 新增陪玩类目
     */
    @PreAuthorize("@ss.hasPermi('wq:play:add')")
    @Log(title = "陪玩类目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqPlay wqPlay)
    {
        return toAjax(wqPlayService.insertWqPlay(wqPlay));
    }

    /**
     * 修改陪玩类目
     */
    @PreAuthorize("@ss.hasPermi('wq:play:edit')")
    @Log(title = "陪玩类目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqPlay wqPlay)
    {
        return toAjax(wqPlayService.updateWqPlay(wqPlay));
    }

    /**
     * 删除陪玩类目
     */
    @PreAuthorize("@ss.hasPermi('wq:play:remove')")
    @Log(title = "陪玩类目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqPlayService.deleteWqPlayByIds(ids));
    }
}
